Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reparent AmbiguousOutputError onto AttributeError #595

Merged
merged 2 commits into from
Feb 17, 2025
Merged

Reparent AmbiguousOutputError onto AttributeError #595

merged 2 commits into from
Feb 17, 2025

Conversation

liamhuber
Copy link
Member

Just conceptually errors being raised from __getattr__ ought to be this way anyhow, not ValueError. But more importantly, raising a ValueError instead of an AttributeError meant that the builtin hasattr method couldn't properly return False when the lookup failed due to not having an unambiguous .channel attribute to which to delegate the lookup.

Since we redirect __getitem__ to __getattr__, maybe AmbiguousOutputError should have dual inheritance with AttributeError and KeyError. However, this PR is really to address the key problem that hasattr is failing. Since I didn't have to touch the rest of the test suite, it seems to have accomplished it without any other side effects. I'd like to delay further modifications until a clear need appears.

Just conceptually errors being raised from `__getattr__` ought to be this way anyhow, not `ValueError`. But more importantly, raising a `ValueError` instead of an `AttributeError` meant that the builtin `hasattr` method couldn't properly return `False` when the lookup failed due to not having an unambiguous `.channel` attribute to which to delegate the lookup.

Signed-off-by: liamhuber <[email protected]>
Copy link

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_workflow/hasattr

Copy link

codacy-production bot commented Feb 16, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d55bb2a) 3423 3127 91.35%
Head commit (3886b82) 3422 (-1) 3126 (-1) 91.35% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#595) 4 4 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@coveralls
Copy link

coveralls commented Feb 16, 2025

Pull Request Test Coverage Report for Build 13357835816

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.003%) to 91.35%

Files with Coverage Reduction New Missed Lines %
mixin/single_output.py 2 97.5%
Totals Coverage Status
Change from base Build 13349521211: -0.003%
Covered Lines: 3126
Relevant Lines: 3422

💛 - Coveralls

Signed-off-by: liamhuber <[email protected]>
@liamhuber liamhuber merged commit bd13cc3 into main Feb 17, 2025
20 checks passed
@liamhuber liamhuber deleted the hasattr branch February 17, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants